<?php 

$username = $_POST['username'];

$preg = "/^[0-9A-z]{6,8}$/";

$c = preg_match($preg, $username);

if(!$c){
	$arr = array(
		'error' =>0,
		'info'=>"用户名必须是6-8位的字母与数字"
		);
	echo json_encode($arr);
	exit;
}

$user = include './user.php';

foreach ($user as $v) {
	if($v['username']==$username){
		$arr = array(
			'error' =>0,
			'info'=>"用户名已存在"
			);
		echo json_encode($arr);
		exit;
	}
}


$arr = array(
		'error' =>1,
		'info'=>"用户名可用"
		);
echo json_encode($arr);




















 ?>